<?php
	include_once "../conf/conf.site.inc.php";
	include_once "class.mysql.php";
	include_once "functions.class.php";
	include_once "functions.php";
	
	class eleve extends functions {
		var $objMysql;
		
		// Constructeur
		function eleve ($objMysql = false) {
			if ($objMysql) {
				$this->objMysql = $objMysql;
			}
			else {
				$this->objMysql = connexion();
			}
		}
		
		// Destructeur
		function _eleve () {
			deconnexion();
		}
		
		function eleveSearch ($idParent) {
			$reqGetEleve = "SELECT AU.NOM, AU.PRENOM, AE.ID_ELEVE, DATE_FORMAT(AE.DATE_NAISSANCE, '%d/%m/%Y') AS DATE_NAISSANCE, AE.SEXE
			FROM arabe_eleve AE
			INNER JOIN arabe_user AU ON AU.ID_USER = AE.ID_USER
			WHERE AE.ID_PARENT = '" . $idParent . "'";
						
			$result = $this->objMysql->MysqlSelectPerso($reqGetEleve);
			if (count($result) > 0) {
				return $result;
			}
			else {
				return 0;
			}
		}
		
		function eleveGetInscription ($idEleve) {
			$reqGetInscription = "SELECT *
                        FROM arabe_inscription AI
                        WHERE AI.ID_ELEVE = '" . $idEleve . "'";
								
			$result = $this->objMysql->MysqlSelectPerso($reqGetInscription);
			if (count($result) > 0) {
				return $result;
			}
			else {
				return 0;
			}
		}
		
		function eleveInscriptionCoran ($idInscription, $etatInscription) {
			$reqUpdateInscription = "UPDATE arabe_inscription SET CORAN = " . $etatInscription . " WHERE ID_INSCRIPTION = '" . $idInscription . "'";
			$restlt = $this->objMysql->MysqlQuery ($reqUpdateInscription);
			
			if ($result) {
				return $reqUpdateInscription;
			}
			else {
				return $reqUpdateInscription;
			}
		}
		
		function eleveInscriptionArabe ($idInscription, $etatInscription) {
			$reqUpdateInscription = "UPDATE arabe_inscription SET ARABE = " . $etatInscription . " WHERE ID_INSCRIPTION = '" . $idInscription . "'";
			$restlt = $this->objMysql->MysqlQuery ($reqUpdateInscription);
			
			if ($result) {
				return $reqUpdateInscription;
			}
			else {
				return $reqUpdateInscription;
			}
		}

		function newEleve ($sexe, $dateNaissance, $idUser, $idParent) {
			$values = array ("SEXE" => $sexe,
                            "DATE_NAISSANCE" => $dateNaissance,
                            "ID_USER" => $idUser,
                            "ID_PARENT" => $idParent);

			$result = $this->objMysql->MysqlInsert("arabe_eleve", $values);
			if ($result) {
				return $this->objMysql->DernierID;
			}
			else {
				return false;
			}
		}
	}
?>